import {
  convertDateTimeToBeijingTime,
  convertToTodayTime,
} from "@/utils/time-utils";

export const formatTimestamp = (timestamp: number): string => {
  const now = Date.now();
  const diffInSeconds = Math.floor((now - timestamp) / 1000);

  if (diffInSeconds < 60) return "刚刚";
  if (diffInSeconds < 3600) return `${Math.floor(diffInSeconds / 60)}分钟前`;
  if (diffInSeconds < 86400) return `${Math.floor(diffInSeconds / 3600)}小时前`;
  if (diffInSeconds < 604800) return `${Math.floor(diffInSeconds / 86400)}天前`;

  // 使用项目中的时间格式化函数
  return convertToTodayTime(convertDateTimeToBeijingTime(timestamp));
};
